<template>
	<view class="content">
		<view class="login-title">
			<view class="login-title1">登录</view>
			<view class="login-title2"></view>
		</view>
		<view class="login-content">
			<view class="login-content-top">
				<view class="login-content-top1">账号</view>
				<input type="text" value="" placeholder="请输入手机号" placeholder-class="sjhinput" v-model="shouji"/>
			</view>
			<view class="login-content-bottom">
				<view class="login-content-bottom1">密码</view>
				<input type="text" value="" placeholder="请输入手机号" placeholder-class="sjhinput" v-model="password"/>
			</view>
		</view>
		<!-- 按钮 -->
		<view class="bottom-btn">
			<view class="bottom-btn1" @click="goHome">
				登录
			</view>
			<view class="bottom-btn2" @click="goRegister">
				注册账号
			</view>
		</view>
		<view class="wj" @click="goForget">
			<view class="wj1">忘记密码?</view>
		</view>
		<!-- w微信手机号登录 -->
		<view class="disanfang">
			<view class="shouji3">
				<navigator url="./mobile">
					<view class="shouji3-img">
										<image src="../../static/home/iphone.png" mode=""></image>
									</view>
									<view class="shouji3-title">
										手机号登录
									</view>
				</navigator>
				
			</view>
			<view class="weixin3" @click="goWechat">
					<view class="weixin3-img">
						<!-- <image src="../../static/home/weixin.png" mode=""></image> -->
					</view>
					<view class="weixin3-title">
						<!-- 微信登录 -->
					</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shouji: '15624335216', //手机号
				password: '12345678', // 密码
				// 邀请码
				invitation: '1',
			};
		},
	
		methods:{
			goWechat() {
				// 1111
				
				// 1111
				var that = this
				that.$http.req.ajax({
				     path: ':8066/web/lxUser/loginWeChat',
				     data: {
				     // weChatCode:that.,
					 shareCode:that.invitation
				     },
				     afterAjax: (res) => {
								if(res.code==200){
								console.log(res,'微信登录')
									uni.showToast({
										title:'微信登录成功'
									})
									
									uni.setStorageSync('token',res.token)
									console.log(token)
									uni.setStorageSync('userId',res.userId)
									setTimeout( () => {
									  uni.switchTab({
									  	url:'../home/new_file'
									  })
									}, 500)
									
									
								}
								
						 	
				     }
				    })
			},
			appLogin: function() {
			        uni.getProvider({
			          service: 'oauth',
			          success: function(res) {
			            //支持微信、qq和微博等
			            if (~res.provider.indexOf('weixin')) {
			              uni.login({
			                provider: 'weixin',
			                success: function(loginRes) {
			                  let access_token = loginRes.authResult.access_token
			                  let openid = loginRes.authResult.openid
			                  console.log('-------获取openid(unionid)-----');
			                  console.log('token',access_token)
			                  console.log('openid',openid)
			                  console.log(JSON.stringify(loginRes));
			                  // 获取用户信息
			                  uni.getUserInfo({
			                      provider: 'weixin',
			                      success: function(infoRes) {
			                        console.log('-------获取微信用户所有-----');
			                        console.log(JSON.stringify(infoRes.userInfo));
			                      }
			                  });
			                }
			              });
			            }
			          }
			        });
			},
			goRegister() {
				uni.navigateTo({
					url: 'register'
				})
			},
			goForget() {
				uni.navigateTo({
					url: 'forget'
				})
			},
			goHome() {
				var that = this
				that.$http.req.ajax({
				     path: ':8066/web/lxUser/loginPwd',
				     data: {
				     telPhone:that.shouji,
					 userPwd:that.password
				     },
				     afterAjax: (res) => {
						 	
								if(res.code==200){
									console.log(res,'登录')
									uni.showToast({
										title:'登录成功'
									})
									uni.setStorageSync('token',res.token)
									uni.setStorageSync('userId',res.userId)
									uni.switchTab({
										url:'../home/home'
									})
									// setTimeout( () => {
									//   uni.switchTab({
									//   	url:'../home/home'
									//   })
									// }, 500)	
								} 	
				     }
				    })
			}
		}
	}
</script>

<style lang="scss">
.content {
		min-width: 722rpx;
		max-width: 1358rpx;
		margin: 0 auto;
		.login-title {
			display: flex;
			flex-direction: column;
			justify-content: center;
			margin: 94rpx 326rpx 94rpx 326rpx;
			.login-title1 {
				font-size: 43rpx;
			}
			.login-title2 {
				width: 86rpx;
				height: 7rpx;
				background-color: #fcda22;
			}
		}
		.login-content {
			margin: 0 65rpx;
			display: flex;
			flex-direction: column;
			justify-content: flex-end;
			.login-content-top, .login-content-bottom {
				margin: 27rpx 36rpx;
				border-bottom: 1rpx solid #f5f5f5;
				.login-content-top1, .login-content-bottom1 {
					font-size: 21rpx;
				}
				.login-content-top2, .login-content-bottom2 {
					margin: 18rpx 0;
					color: #a8a8a8;
				}
				
			}
			
		}
		// 按钮
		.bottom-btn {
			margin: 54rpx 54rpx 0 54rpx;
			.bottom-btn1, .bottom-btn2 {
				background-color: #fcda22;
				border-radius: 36rpx;
				height: 72rpx;
				line-height: 72rpx;
				text-align: center;
				font-size: 25rpx;
				margin: 21rpx 0;
			}
			.bottom-btn2 {
				background-color: #20212d;
				color: #fcda22;
			}
		}
		.wj {
			width: 100%;
			text-align: center;
			display: flex;
			flex-direction: column;
			justify-content: center;
			.wj1 {
				font-size: 21rpx;
				color: #21201d;
				border-bottom: 1rpx solid #21201d;
				width: 108rpx;
				text-align: center;
				margin: 0 auto;
			}
		}
		// 第三方登录
		.disanfang {
			margin: 25rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			.shouji3 {
				display: flex;
				flex-direction: column;
				justify-content: center;
				.shouji3-img {
					width: 39rpx;
					height: 39rpx;
					margin-left: 30rpx;
					margin-bottom: 10rpx;
					image {
						max-width: 100%;
						max-height: 100%;
					}
				}
				.shouji3-title {
					
					font-size: 25rpx;
					font-weight: 600;
				}
			}
			.weixin3 {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				.weixin3-img {
					width: 39rpx;
					height: 39rpx;
					margin-left: 30rpx;
					margin-bottom: 10rpx;
					image {
						max-width: 100%;
						max-height: 100%;
					}
				}
				.weixin3-title {
					font-size: 25rpx;
					font-weight: 600;
				}
			}
		}
}
</style>
